package com.itheima.wemedia.controller;

import com.itheima.common.vo.ResultVo;
import com.itheima.wemedia.pojo.WmUser;
import com.itheima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ApiController {

    @Autowired
    private WmUserService wmUserService;

    // 通过ap_user_id查询 wm_user表
    @GetMapping("/api/wmUser/getByApUserId/{apUserId}")
    public ResultVo<WmUser> getByApUserId(@PathVariable(value = "apUserId") Long apUserId){
        WmUser wmUser = wmUserService.findByApUserId(apUserId);
        return ResultVo.ok(wmUser);
    }

    // 创建 WmUser 对象
    @PostMapping("/api/wmUser/add")
    public ResultVo<WmUser> addWmUser(@RequestBody WmUser wmUser){
        wmUserService.save(wmUser);
        return ResultVo.ok(wmUser);
    }
}
